package com.mine.photohandler.adapter;

import android.content.Context;
import android.view.View;

import com.mine.photohandler.R;
import com.mine.photohandler.base.AbsBaseAdapter;
import com.mine.photohandler.util.Bimp;
import com.mine.photohandler.util.ImageItem;
import com.mine.photohandler.util.PublicWay;

public class PhotoAdapter extends AbsBaseAdapter<ImageItem> {

    public PhotoAdapter(Context context, boolean isNeedToRemember, int resid) {
        super(context, isNeedToRemember, resid);
    }

    @Override
    public void bindDatas(int position, View convertView, ViewHolder viewHolder, ImageItem data) {


        if (position == PublicWay.num){ // 已经选够图片，无需再添加
            viewHolder.getView(R.id.item_grida_image).setVisibility(View.GONE);
        }else {
            if (data.isAdd){
                viewHolder.bindImageView(R.id.item_grida_image, R.drawable.icon_addpic_focused);
            }else {
                viewHolder.getView(R.id.item_grida_image).setVisibility(View.VISIBLE);
                if (Bimp.tempSelectBitmap.get(position).getBitmap() != null){
                    viewHolder.bindImageView(R.id.item_grida_image, Bimp.tempSelectBitmap.get(position).getBitmap());
                }else {
                    viewHolder.bindImageView(R.id.item_grida_image, R.drawable.user_icon_default);
                }
            }


        }

    }

}
